#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int MAXN=1e9+7;
const int SIZE=200005;
int t;
int n,m,l,v;
int d[SIZE],V[SIZE],a[SIZE];
int p[SIZE];
int ans;
int st[SIZE];
signed main(){
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>v;
        for(int i=0;i<n;i++){
            cin>>d[i]>>V[i]>>a[i];
                st[i]=floor((v*v-V[i])/2*a[i]);
        }
        for(int i=0;i<m;i++){
            cin>>p[i];
        }
        for(int i=0;i<n;i++){
            int j=*upper_bound(p,p+n,d[i]+st[i]+1);
            if(j!=n){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
